
<table class="layui-hide" id="test"></table>


<script>
    layui.use('table', function(){
        var table = layui.table;

        table.render({
            elem: '#test'
            ,url:'/users/userlist'
            ,page:true
            ,cols: [[
                {field:'id', title: 'ID', sort: true}
                ,{field:'username',  title: '用户名'}
                ,{field:'gender', title: '性别', sort: true
                    ,templet:function (data) {
                        return data.gender==1?'<span class="layui-badge layui-bg-green" >男</span>':'<span class="layui-badge layui-bg-red" >女</span>'
                    }
                }
                ,{field:'regist_time', title: '注册日期' }
            ]]
        });
    });
</script>
